package com.decent.ejfadmin.report.dao.provider;


import com.decent.ejfadmin.common.enums.ExkChannelPlat;

import java.util.HashMap;

/**
 * 收卡利润统计
 *
 * @author starSky
 * @date 2/25/2018 11:18 AM.
 */
public class CollectCardProfitDailyReportDaoProvider {
    public String queryDailyReport(HashMap<String, Object> param) {
        StringBuffer sql = new StringBuffer(100);
        sql.append("SELECT P.productType, " +
                " SUM(P.successTotal) AS successTotal, " +
                " SUM(P.failTotal) AS failTotal, " +
                " SUM(P.sales) AS SALES, " +
                " SUM(P.costs) AS costs, " +
                " SUM(P.salesFee) AS salesFee, " +
                " SUM(P.chargeFee) AS chargeFee, " +
                " SUM(P.profit) AS profit, " +
                " SUM(P.totalFace) AS totalFace," +
                " SUM(P.xianyuCommission) AS xianyuCommission " +
                "FROM " +
                " `yuhuang_supply_card_profit` P");
        sql.append(" WHERE P.DATE>=#{startTime} AND P.DATE<=#{endTime} ");
        ExkChannelPlat exkChannelPlat = (ExkChannelPlat) param.get("channel");
        if (ExkChannelPlat.EJF.equals(exkChannelPlat)) {
            sql.append(" AND P.agentNo  IN ('13950','14165')");
        }
        if (ExkChannelPlat.EFW.equals(exkChannelPlat)) {
            sql.append(" AND P.agentNo  IN ('13630','14350','18370')");
        }
        sql.append(" GROUP BY P.PRODUCTTYPE");
        return sql.toString();
    }
}
